package nestAdress;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class inetAdress {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress inetAddress=InetAddress.getLocalHost();
        System.out.println(inetAddress);//ppp/10.110.126.51

        //通过主机名获取对象地址
        InetAddress host=InetAddress.getByName("ppp");
        System.out.println("主机地址"+host);
        InetAddress hose1=InetAddress.getByName("www.baidu.com");
        System.out.println("百度地址"+hose1);
        //获取主机地址
        System.out.println(inetAddress.getHostAddress());
        //获取主机名
        System.out.println(inetAddress.getHostName());

    }
}
